package com.besovideo.mpu;

import org.opencv.facetrackmatch.facedetect.FaceTrackTool;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

public class RecogintionListDialog extends Dialog {
	Context context;
	FaceTrackTool faceTrackTool;
	int lay;
	boolean mDetectListNum;
	RadioGroup m_RadioGroup;
	private RadioButton m_RadioButtonRecogitionListOpen;
	private RadioButton m_RadioButtonRecogitionListClose;

	public RecogintionListDialog(Context context, FaceTrackTool faceTrackTool) {
		super(context, R.style.TransparentDialogHaveTitle);
		this.context = context;
		this.faceTrackTool = faceTrackTool;
		this.lay = R.layout.recognition_list_dialog;
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.setContentView(lay);

		m_RadioGroup = (RadioGroup) findViewById(R.id.radioGroupListRecogition);
		m_RadioButtonRecogitionListOpen = (RadioButton) findViewById(R.id.radioGroupListRecogitionOpen);
		m_RadioButtonRecogitionListClose = (RadioButton) findViewById(R.id.radioGroupListRecogitionClose);

		SelectSet();
		m_RadioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

			@Override
			public void onCheckedChanged(RadioGroup group, int checkedId) {
				// TODO Auto-generated method stub
				if (checkedId == m_RadioButtonRecogitionListOpen.getId()) {
					faceTrackTool.setmDetectListNum(true);
				} else {
					faceTrackTool.setmDetectListNum(false);
				}
				dismiss();
			}
		});
	}

	private void SelectSet() {
		boolean temp = faceTrackTool.getmDetectListNum();
		if (temp) {
			m_RadioGroup.check(m_RadioButtonRecogitionListOpen.getId());
		} else {
			m_RadioGroup.check(m_RadioButtonRecogitionListClose.getId());
		}
	}
}
